<!DOCTYPE html>
<html lang="en">

<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
</head>

<body>
    <script>
        window.App = {};
/*
以下是菜单数据提取查询语句，数据库来源于若依分离版postgresql实现的示例数据
with
    menu as (       
		select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.visible, m.status, 
			COALESCE(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time, u.user_id
		from sys_menu m
		left join sys_role_menu rm on m.menu_id = rm.menu_id
		left join sys_user_role ur on rm.role_id = ur.role_id
		left join sys_role ro on ur.role_id = ro.role_id
		left join sys_user u on ur.user_id = u.user_id
		where   m.menu_type in ('M', 'C') and m.status = 0  AND ro.status = '0'
		order by m.parent_id, m.order_num
		),
	mx as (
			select menu_id, parent_id, menu_name from menu
		)
		
		
--select * from menu;		
--select * from mx;

SELECT array_to_json(array_agg(mx))::text FROM  mx;
*/
        console.log("菜单数据一般从数据库中select出来，并进行了排序。\n一般而言，就是在应用数据来源上，已经保证了父节点节点数据，一定出现在子节点数据之前。");

        var ry_menu_data = [
            {  "menu_id": 1,   "parent_id": 0, "menu_name": "系统管理"             },
            {  "menu_id": 2,   "parent_id": 0, "menu_name": "系统监控"             },
            {  "menu_id": 3,   "parent_id": 0, "menu_name": "系统工具"             },
            {  "menu_id": 4,   "parent_id": 0, "menu_name": "江某人官网"           },
            {  "menu_id": 100, "parent_id": 1, "menu_name": "用户管理"             },
            {  "menu_id": 101, "parent_id": 1, "menu_name": "角色管理"             },
            {  "menu_id": 102, "parent_id": 1, "menu_name": "菜单管理"             },
            {  "menu_id": 103, "parent_id": 1, "menu_name": "部门管理"             },
            {  "menu_id": 104, "parent_id": 1, "menu_name": "岗位管理"             },
            {  "menu_id": 105, "parent_id": 1, "menu_name": "字典管理"             },
            {  "menu_id": 106, "parent_id": 1, "menu_name": "参数设置"             },
            {  "menu_id": 107, "parent_id": 1, "menu_name": "通知公告"             },
            {  "menu_id": 108, "parent_id": 1, "menu_name": "日志管理"             },
            {  "menu_id": 109, "parent_id": 2, "menu_name": "在线用户"             },
            {  "menu_id": 110, "parent_id": 2, "menu_name": "定时任务"             },
            {  "menu_id": 111, "parent_id": 2, "menu_name": "数据监控"             },
            {  "menu_id": 112, "parent_id": 2, "menu_name": "服务监控"             },
            {  "menu_id": 113, "parent_id": 2, "menu_name": "缓存监控"             },
            {  "menu_id": 114, "parent_id": 3, "menu_name": "表单构建"             },
            {  "menu_id": 115, "parent_id": 3, "menu_name": "代码生成"             },
            {  "menu_id": 500, "parent_id": 108,"menu_name": "操作日志"            },
            {  "menu_id": 501, "parent_id": 108, "menu_name": "登录日志"           }
        ]

        var tree_impl_1 = function(data){
            

        }

        var tree_impl_2 = function(data){

        }
        
        tree_impl_1(ry_menu_data);
        tree_impl_2(ry_menu_data);
        


    </script>

</body>

</html>